alfred: Fix procd process handling for disable state
authorSven Eckelmann <[email protected]>
Mon, 15 Feb 2021 20:03:57 +0000 (21:03 +0100)
committerSven Eckelmann <[email protected]>
Mon, 15 Feb 2021 20:28:09 +0000 (21:28 +0100)
Alfred can be stopped during a (re)start or reload when:

* disabled = 1
* batman-adv interface is missing
* MAC based EUI64 IPv6 link-local address not set

It is assumed that procd detects that the procd instance definition
disappeared and the currently running instance must be stopped. But all
these checks were triggering an "exit" which then stopped the alfred init
script and the wrapper from /lib/functions/procd.sh. And thus procd was
never informed about the instances which should be changed.

The correct handling is to return the result of the function instead of
directly killing the init scripts.

Fixes: 45db0e60d2ff ("alfred: use procd")
Signed-off-by: Sven Eckelmann <[email protected]>
alfred/Makefile
alfred/files/alfred.init

index 66e82ce7c2db65955ec87ea066bf8974f33c9b7b..ad38845ddf0077dbadcb52c039d4a1235db49b44 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=alfred
 PKG_VERSION:=2019.2
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_HASH:=b656f0e9a97a99c7531b6d49ebfd663451c16cdd275bbf7d48ff8daed3880bf2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
index 89e33ab55a0bd301fcd6ae490a5e93b7f92c2bd2..b2dc9d85dd0e0855fc7e7e7979ecf47b62084dba 100755 (executable)
@@ -24,10 +24,12 @@ wait_for_dir() {
                        [ -d "$dir" ] && break
                        if [ $i = $timeout ] ; then
                                echo "$ifce not detected, alfred not starting."
-                               exit 1
+                               return 1
                        fi
                done
        fi
+
+       return 0
 }
 
 wait_for_ll_address() {
@@ -45,13 +47,13 @@ wait_for_ll_address() {
                        $1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 == "'"$iface"'" { RET=0 }
                        END { exit RET }
                ' /proc/net/if_inet6; then
-                       return
+                       return 0
                fi
                sleep 1
        done
 
        echo "$iface address not detected, alfred not starting."
-       exit 1
+       return 1
 }
 
 alfred_start() {
@@ -75,7 +77,7 @@ alfred_start() {
        append args "-b $batmanif"
 
        if [ "$batmanif" != "none" ]; then
-               wait_for_dir "$batmanif" "/sys/class/net/$batmanif/mesh"
+               wait_for_dir "$batmanif" "/sys/devices/virtual/net/$batmanif" || return 1
        fi
 
        wait_for_ll_address "$interface"
@@ -98,7 +100,7 @@ start_service() {
        config_load "alfred"
        config_foreach alfred_start alfred
 
-       [ "$enable" = "0" ] && exit 0
+       [ "$enable" = "0" ] && return 0
 
        procd_open_instance "alfred"
        procd_set_param command /usr/sbin/alfred